﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HolySword.Delegates;
using Styx;
using Styx.TreeSharp;
using Attack = HolySword.Helpers.AttackManager;
using Guild = HolySword.Helpers.Guild;
using Logger = HolySword.Helpers.LogManager;
using Movement = HolySword.Helpers.MovementManager;
using Paladin = HolySword.Helpers.Paladin;
using Professions = HolySword.Helpers.Professions;
using Racials = HolySword.Helpers.Racials;
using Spell = HolySword.Helpers.Spell;
using TargetManager = HolySword.Helpers.TargetManager;
using Styx.WoWInternals.WoWObjects;

namespace HolySword.Behaviours
{
    class Pull
    {
        private static LocalPlayer Me = HolySword.Me;

        public static Composite DoRetribution(UnitSelectionDelegate target, SimpleBooleanDelegate condition)
        {
            return DoHoly(target, condition);
        }

        public static Composite DoProtection(UnitSelectionDelegate target, SimpleBooleanDelegate condition)
        {
            return DoHoly(target, condition);
        }

        public static Composite DoHoly(UnitSelectionDelegate target, SimpleBooleanDelegate condition)
        {
            return new Decorator(ret => target != null && condition != null && condition(ret),
                            new PrioritySelector(
                                TargetManager.NeedTarget(),
                                Movement.CreateEnsureMovementStoppedBehavior(),
                                Movement.CreateFaceTargetBehavior(),
                                Movement.CreateMoveToLosBehavior(),
                                Spell.CastSpell(Paladin.Judgment, ret => StyxWoW.Me.CurrentTarget, ret => true, "[Pull]"),
                                Spell.CastSpell(Paladin.HolyShock, ret => StyxWoW.Me.CurrentTarget, ret => true, "[Pull²]"),
                                Spell.CastSpell(Paladin.Denounce, ret => StyxWoW.Me.CurrentTarget, ret => true, "[Pull³]"),
                                Attack.CreateAutoAttack()
                                )
                       );
        }
    }
}
